// pages/exchange/exchange.js
var a = getApp(), t = a.requirejs("core"), e = a.requirejs("biz/order");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    exchangeCode:''
  },
  electronActi(e){
    console.log(e,89)
    var id = e.currentTarget.dataset.id;
    // wx.navigateTo({
    //   url: '/pages/exchange/activation/index?id=' + id,
    // })
    t.get('member/activespendings', { id: id }, function (e) {
      console.log(e, 8888)

      if (e.status == 0) {
        wx.showToast({
          title: e.message,
          icon: 'none',
          duration: 1500
        })
      } else if (e.status == 1) {
        wx.navigateTo({
          url: '/pages/exchange/activation/index?id='+ id,
        })
      }
    })
  },
  getCode(e){
    var code = e.detail.value;
    this.setData({
      exchangeCode: code
    })
  },
  exchange(e){
    var that =this;
   
    var code = that.data.exchangeCode;
    console.log(code, 55555);
    t.get('member/activespending', {code:code}, function (e) {
      console.log(e, 8888)

      if (e.status==0){
        wx.showToast({
          title: e.message,
          icon: 'none',
          duration: 1500
        })
      } else if (e.status == 1){
        wx.navigateTo({
          url: '/pages/exchange/activation/index?code='+code,
        })
      }
    })
    
 
    
   
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    t.get('member/getmyrchargecoupon', { }, function (e) {
      console.log(e, 8888)
      that.setData({
        list:e.data
      })
  
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    t.get('member/getmyrchargecoupon', {}, function (e) {
      console.log(e, 8888)
      that.setData({
        list: e.data
      })

    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})